- /* existdir.cpp by K. Tsuru*/
- /************************************
- It returns whether the directory exist or not.
- *************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
-
- static const char* const testFile ="$$$.$$$";
-
- bool ExistDirectory(const char* const dir){
- FILE* fp;
- char fname[SNC_MAX_PATH];
- bool create = true;
-
- strcpy(fname, dir);
- char* lc = LastChar(fname);
- if(*lc != DIR_SEPARATOR){ // no separator of directory
- *(lc+1) = DIR_SEPARATOR; *(lc+2) = '\0';
- }
- strcat(fname, testFile);
-
- fp = fopen(fname, "r"); // try to read
- if(fp == NULL) fp = fopen(fname, "w");// create
- else create = false;
-
- if(fp != NULL){
- fclose(fp); if(create) remove(fname); return true;
- }
- return false;
- }
existdir.cpp : last modifiled at 2017/12/24 15:29:49(757 bytes)
created at 2016/04/11 11:17:20
The creation time of this html file is 2017/12/24 15:31:13 (Sun Dec 24 15:31:13 2017).